package abq2.jic.jic.plugin.operate.fastShowAI;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.operate.FormOperate;
import kd.bos.servicehelper.DispatchServiceHelper;
import kd.sdk.plugin.Plugin;

import java.util.EventObject;

public class ShowAIAskForLeave extends AbstractBillPlugIn implements Plugin {
    @Override
    public void registerListener(EventObject e) {
        super.registerListener(e);
        this.addClickListeners("abq2_show_ai");
    }

    @Override
    public void itemClick(ItemClickEvent evt) {
        super.itemClick(evt);
        String itemKey = evt.getItemKey();
        if (itemKey.equals("abq2_show_ai")){
            String pageId = this.getView().getMainView().getPageId();
            //GPT任务的id编码
            Object pkValue = Long.parseLong("1962590954837786624");
            DispatchServiceHelper.invokeBizService("ai", "gai", "GaiService","selectProcessInSideBar",pkValue,pageId,"此技能用于智能请假");
        }
    }
    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs e) {
        super.beforeDoOperation(e);
        String operateKey = ((FormOperate) e.getSource()).getOperateKey();
        if (operateKey.equals("showai")){
            String pageId = this.getView().getMainView().getPageId();
            //GPT任务的id编码
            Object pkValue = Long.parseLong("1962590954837786624");
            DispatchServiceHelper.invokeBizService("ai", "gai", "GaiService","selectProcessInSideBar",pkValue,pageId,"请输入您的请假信息，我会生成请假申请单");
        }
    }
}
